home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
haeberli
/
libgutil
/
rctgl.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
4KB
|
148 lines
/*
* Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
/*
* rctgl -
* GL code for management of rectangles.
*
* Paul Haeberli - 1986
*/
#include "gl.h"
#include "rct.h"
#include "port.h"
rctrdraw(r,iradius)
rct *r;
int iradius;
{
float delx, dely;
float partx, party;
float radius;
radius = iradius;
if(radius<0)
radius = 0;
delx = r->xmax-r->xmin;
dely = r->ymax-r->ymin;
if(radius > delx)
radius = delx;
if(radius > dely)
radius = dely;
partx = delx - radius;
party = dely - radius;
pushmatrix();
scale(0.5,0.5,1.0);
translate((float)r->xmin+r->xmax,(float)r->ymin+r->ymax,0.0);
pushmatrix();
translate(-partx,-party,0.0);
scale(radius,radius,1.0);
arc(0.0,0.0,1.0,1800,2700);
popmatrix();
move2(-partx,-dely);
draw2( partx,-dely);
pushmatrix();
translate( partx,-party,0.0);
scale(radius,radius,1.0);
arc(0.0,0.0,1.0,2700,3600);
popmatrix();
move2( delx,-party);
draw2( delx, party);
pushmatrix();
translate( partx, party,0.0);
scale(radius,radius,1.0);
arc(0.0,0.0,1.0,0,900);
popmatrix();
move2( partx, dely);
draw2(-partx, dely);
pushmatrix();
translate(-partx, party,0.0);
scale(radius,radius,1.0);
arc(0.0,0.0,1.0,900,1800);
popmatrix();
move2(-delx, party);
draw2(-delx,-party);
popmatrix();
}
rctrfill(rr,iradius)
rct *rr;
int iradius;
{
int delx, dely;
float partx, party;
float radius;
rct *r, *fr;
if(iradius<0)
iradius = 0;
r = rctclone(rr);
delx = r->xmax-r->xmin;
dely = r->ymax-r->ymin;
if(iradius > delx)
iradius = delx;
if(iradius > dely)
iradius = dely;
partx = delx - iradius;
party = dely - iradius;
radius = iradius - 0.4;
pushmatrix();
scale(0.5,0.5,1.0);
translate((float)r->xmin+r->xmax,(float)r->ymin+r->ymax,0.0);
fr = rctnew();
rctset(fr,(int)-partx,-dely,(int)partx,dely);
rctfill(fr);
rctset(fr,-delx,(int)-party,delx,(int)party);
rctfill(fr);
rctfree(fr);
pushmatrix();
translate(-partx,-party,0.0);
scale(radius,radius,1.0);
arcf(0.0,0.0,1.0,1800,2700);
popmatrix();
pushmatrix();
translate(partx,-party,0.0);
scale(radius,radius,1.0);
arcf(0.0,0.0,1.0,2700,3600);
popmatrix();
pushmatrix();
translate(partx,party,0.0);
scale(radius,radius,1.0);
arcf(0.0,0.0,1.0,0,900);
popmatrix();
pushmatrix();
translate(-partx,party,0.0);
scale(radius,radius,1.0);
arcf(0.0,0.0,1.0,900,1800);
popmatrix();
popmatrix();
rctfree(r);
}
rctdraw(r)
rct *r;
{
drawrect((float)r->xmin,(float)r->ymin,(float)r->xmax,(float)r->ymax);
}
rctfill(r)
rct *r;
{
fillrect((float)r->xmin,(float)r->ymin,(float)r->xmax,(float)r->ymax);
}